<template>
  <div>
    <div
      class="add"
      v-if="active == 0"
      @click="add()"
    >新增</div>
    <eagle-list
    :showTab="false"
      :tabData="tabData"
      @initActive="_initActive"
      @bindData="bindData"
      :filterParams="filterParams"
      :filterParamsDefaul="filterTabDefault"
      :filterTab="filterTab"
      :placeholder="placeholder1"
      ref="eaglelist"
    >
        <eagle-cell
          style="margin-top: 10px"
          class="card"
          v-for="(item, index) in list"
          :key="index"
        >
          <div>
            <div @click="goToDetail(item)">
              <div class="warn_header">
                <div>{{ item.PlanName }}</div>
              </div>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  /> 最近复审日期：{{ item.CheckDay | formatDate }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  /> 下次复审日期：{{ item.NextCheckDay | formatDate }}
                </eagle-col>
              </eagle-row>
              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />录入人：{{ item.CreateChnName ? item.CreateChnName : "无" }}
                </eagle-col>
              </eagle-row>

              <eagle-row
                gutter="20"
                class="dep_sort"
              >
                <eagle-col span="24">
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  /> 录入时间：{{ item.CreateDate | formatDate }}
                </eagle-col>
              </eagle-row>
            </div>
            <van-divider />
            <div class="op_btn">
              <div
                class="btn_item"
                @click="goToEdit(item)"
              >
                <img
                  src="@/assets/Images/AppIcon/icon_list_abolish.png"
                  alt=""
                />
                <div class="mr-10">编辑</div>
              </div>
              <div
                class="btn_item"
                
                @click="del(item)"
              >
                <img
                  src="@/assets/Images/AppIcon/icon_list_edit.png"
                  alt=""
                />
                <div class="mr-10">删除</div>
              </div>
            </div>
          </div>
        </eagle-cell>
    </eagle-list>
  </div>
</template>

<script>
import { getDate } from "@/utils/getDate";
export default {
  data() {
    return {
      active: 0,
      list: [],
      filterTab: true,
      placeholder1: "",
      Code:'',
      tabData: [
        {
          title: "证书复检记录",
          url: "/SiteCertCheckHis/GetPageData",
          isPage: true,
          params: {
            dataType: "List",
            code:this.$route.query.Code
          },
        },
      ],
      filterParams: [
        {
          name: "PlanType",
          title: "不限",
          originTitle: "不限",
          dataType: "String",
          data: [
            { text: "不限", value: "" },
            { text: "综合预案", value: "A" },
            { text: "专项预案", value: "B" },
            { text: "现场处置方案", value: "C" },
            { text: "应急资源调查", value: "D" },
            { text: "应急资源调查", value: "F" },
          ],
        },
      ],
      filterTabDefault:[{ name: "不限", value: "" }],
    };
  },
  created() {
    this.Code=this.$route.query.Code
  },
  filters: {
    formatDate: function (value, args) {
      return getDate(value);
    },
  },
  methods: {
    _initActive(active) {
      if (active === 0) {
        this.$refs.eaglelist.changefilterTab(true);
        this.placeholder1 = "请输入岗位,姓名搜索";
      }
      if (active === 1) {
        this.$refs.eaglelist.changefilterTab(false);
        this.placeholder1 = "请输入文件名称搜索";
      }
      this.active = active;
    },
    bindData(data) {
      this.list = data;
    },
    goToDetail(item) {
      this.$router.push({
        path: "/Site_Cert/CertCheckHis/Detail",
        query: { id: item.ID },
      });
    },

    goToEdit(item) {
      this.$router.push({
        path: "/Site_Cert/CertCheckHis/Edit",
        query: { id: item.ID },
      });
    },
    // 新增/编辑
    add() {
      this.$router.push({
        path: "/Site_Cert/CertCheckHis/Add",
        query: { id: 0 ,Code:this.Code},
      });
    },

    del(item) {
      const _this = this;
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定删除本条信息吗？",
        })
        .then(() => {
          _this.$axios
            .get("/SiteCertCheckHis/Delete", { params: { id: item.ID } })
            .then((res) => {
              _this.$toast.success("删除成功！");
              setTimeout(() => {
                _this.$refs.eaglelist.getList();
              }, 300);
            })
            .catch((err) => {
              console.log("err", err);
            });
        })
        .catch(() => {
          // on cancel
        });
    },

    // 附件详情

    goFile(attachCode) {
      this.$router.push("/Attach/AatachDetail?attCode=" + attachCode);
    },

    // 查看报告
    lookPdf(item, ids) {
      this.$router.push({
        name: "CheckReportDetail2",
        query: {
          url: process.env.VUE_APP_BASE_API + item.PdfAttach,
          TypeName: this.titleCode,
          isSignature: "ResponsibilityOrgPostUserDepositManage",
          IDS: ids,
          DocCode: item.Code,
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.phone {
  position: relative;
  .code {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 12px;
  }
}
.register-info {
  background-color: #e8f1f8;
  padding-bottom: 20px;
}
.img-box {
  height: 50px;
  width: 50px;
  padding: 10px;
  position: absolute;
  left: 50%;
  top: 60px;
  background-color: #fff;
  border-radius: 50%;
  overflow: hidden;
}
.popup-title {
  line-height: 35px;
  padding: 10px;
  font-size: 15px;
  padding-left: 20px;
}

.op_btn {
  display: flex;
  justify-content: flex-end;
  .btn_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>
